package com.agritech.smartfarming.chainofresponsibility;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 安全事件类，用于责任链模式
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SafetyEvent {
    /**
     * 安全事件类型枚举
     */
    public enum EventType {
        OBSTACLE_DETECTED("障碍物检测"),
        BOUNDARY_BREACH("边界突破"),
        MACHINE_FAULT("设备故障"),
        COLLISION_RISK("碰撞风险"),
        WEATHER_WARNING("恶劣天气"),
        COMMUNICATION_LOSS("通信中断"),
        UNAUTHORIZED_ACCESS("未授权访问");
        
        private final String description;
        
        EventType(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
    
    private EventType type;             // 事件类型
    private String description;         // 事件描述
    private int severity;               // 严重程度 (1-5，5为最严重)
    private long timestamp;             // 事件发生时间戳
    
    /**
     * 创建一个新的安全事件
     * @param type 事件类型
     * @param description 事件描述
     * @param severity 严重程度
     */
    public SafetyEvent(EventType type, String description, int severity) {
        this.type = type;
        this.description = description;
        this.severity = severity;
        this.timestamp = System.currentTimeMillis();
    }
    
    @Override
    public String toString() {
        return String.format("安全事件 [类型: %s, 严重程度: %d/5, 描述: %s]",
                type.getDescription(), severity, description);
    }
} 